package week2.mapreduce;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FlowMapper extends Mapper<Object, Text, Text, bean> {
    @Override
    protected void map(Object key, Text value, Mapper<Object, Text, Text, bean>.Context context) throws IOException, InterruptedException {
        //value 表示 输出进来的一行
        //输出的key表示手机号码 输出的value可以表示的是类或者Text
        Text keyout = new Text();
        bean valueout = new bean();
        String[] parts = value.toString().split("\t");
        //1363157985066 	13726230503	00-FD-07-A4-72-B8:CMCC	120.196.100.82	i02.c.aliimg.com		24	27	2481	24681	200
        String phonenum = parts[1];
        long upflow = Long.parseLong(parts[parts.length - 3]);
        long downflow = Long.parseLong(parts[parts.length - 2]);
        keyout.set(phonenum);
        valueout.set(upflow, downflow);
        context.write(keyout, valueout);
    }
}
